<?php
/**
 * 订单页
 *
 *
 *
 *
 * @copyright  Copyright (c) 2007-2013 ShopNC Inc. (http://www.shopnc.net)
 * @license    http://www.shopnc.net
 * @link       http://www.shopnc.net
 * @since      File available since Release v1.1
 */
defined('InShopNC') or exit('Access Invalid!');

class orderControl extends MobileControl{

    /**
     * 构造函数
     */
    public function __construct() {
        parent::__construct();
        if (!$_SESSION['member_id']){
            redirect('index.php?act=login&ref_url='.urlencode(request_uri()));
        }
        //验证该会员是否禁止购买
        $member_model =new memberModel();
        $member_id = intval($_SESSION['member_id']);
        $member_info = $member_model->infoMember(array('member_id'=>"{$member_id}"));
        if(empty($member_info) || !$member_info['is_buy']){
            appMessage('您没有商品购买的权限,如有疑问请联系客服人员');
        }
        unset($member_id);
        unset($member_info);
        unset($member_model);
    }
	
    /**
     * 商品付款
     */
    public function order_payOp()
    {

        //购买课程
        $study_id = $_GET['study_id'];


        if (!empty($study_id)) {
            $member_id = $_SESSION['member_id'];
            $rs = "select * from #__study_log where study_id = '" . $study_id . "' and member_id = '" . $member_id . "' ";
            if (Db::queryALL($rs)) {
                showMessage("你已经购买此课程");
            }

            $allamount = universityModel::getstudy_price($study_id);//获取课程价格


            //取得平台支付方式
            $model_payment = new gold_paymentModel();
            //支付方式列表
            $condition = array();
            $condition['payment_state'] = '1'; //可用的支付方式
            $payment_list = $model_payment->getList($condition);
            foreach ((array)$payment_list as $v) {
                if (in_array($v['payment_code'], array('alipaywap', 'cod', 'wxpay', 'tenpay', 'chinapaywap'))) {
                    if ($v['payment_online'] == 1) {
                        $online_array[] = $v;
                    } else {
                        $offline_array[] = $v;
                    }
                }
            }

        } else {
        $order_id = intval($_GET['order_id']);
        if ($order_id <= 0) {
            appMessage('该订单不存在');
        }
        //查询订单信息
        $ordername = 0;
        $allamount = 0;
        $order_ids=array();
        if (is_array($_GET['order_id'])) {
            $order_ids=$_GET['order_id'];
        }else{
            $order_ids[]=$_GET['order_id'];
        }
        foreach ($order_ids as $key => $order_id) {
            $sql="SELECT * FROM #__order as o inner join #__order_address as oa ON o.order_id=oa.order_id where o.order_id='$order_id'";
            $order_info =db::queryRow($sql);
            if (empty($order_info) || $order_info['buyer_id'] != $_SESSION['member_id']) {
                appMessage('该订单不存在');
            }
            
            if($order_info['store_id'] == OFFICIAL_STORE_ID){
                 $sql = "SELECT g.is_transport_dajian FROM #__order_goods AS o LEFT JOIN #__goods AS g ON g.goods_id = o.goods_id WHERE o.order_id = '{$order_info['order_id']}'";
                $goods_list = Db::queryAll($sql);
                $r_f = 0;
                if(is_array($goods_list)){
                    foreach($goods_list as $k=>$v){
                        if($v['is_transport_dajian'] > 0){
                            $r_f = 1;
                        }
                    }
                }
            }

            $sql="SELECT goods_name FROM #__order_goods WHERE ( order_id = '$order_id' ) LIMIT 3";
            $goods_list = db::queryAll($sql);
            $output_goods_name = array();
            foreach ((array)$goods_list as $v) {
                if (count($output_goods_name) < 3) $output_goods_name[] = $v['goods_name'];
            }
            $output_order = $order_info;
            $sql="SELECT member_name FROM #__store WHERE ( store_id = '{$order_info['store_id']}' ) LIMIT 1";
            $output_order['seller_name'] =db::queryOne($sql);
            $output_order['goods_name_data'] = $output_goods_name;
            $order[] = $output_order;
            $ordername++;
            $allamount += $output_order['order_amount'];
            $order_type[] = $order_info['order_type'];
            $order_brand[] = $order_info['brand_id'];            
        };
        //取得平台支付方式
        $model_payment = new gold_paymentModel();
        //支付方式列表
        $condition = array();
        $condition['payment_state'] = '1'; //可用的支付方式
        $payment_list = $model_payment->getList($condition);
        foreach ((array)$payment_list as $v) {
			if(in_array($v['payment_code'],array('alipaywap','alipayapp','cod','tenpay','chinapaywap'))){
                if ($v['payment_online'] == 1) {
                    $online_array[] = $v;
                } else {
                    $offline_array[] = $v;
                }
            }
        }
        
        //查询可用预存款
        $order_type_unique = array_unique($order_type);
        if(count($order_type_unique) == 1 && $order_type_unique[0] == ORDER_TYPE_DEFAULT){
        
            $sql ="select available_predeposit from #__member where member_id = {$_SESSION['member_id']}";
            $available_predeposit = Db::queryOne($sql);
            Tpl::output('is_default_pay', true);
            Tpl::output('available_predeposit', $available_predeposit);
        }        
        
        //加盟采购订单只能用加盟预存款支付
        $order_type_unique = array_unique($order_type);
        if(count($order_type_unique) == 1 && $order_type_unique[0] == ORDER_TYPE_ALLIANCE_BUY){
            
            $order_brand_unique = array_unique($order_brand);
            if(count($order_brand_unique) > 1)
                showMessage('订单信息错误');

            $sql = "select available_deposit, bond from #__brand_alliance where member_id = {$_SESSION['member_id']} and brand_id = $order_brand_unique[0]";
            $available_alliance_deposit_info = Db::queryRow($sql);
            Tpl::output('is_alliance_pay', true);
            Tpl::output('available_alliance_deposit', $available_alliance_deposit_info['available_deposit']);
            Tpl::output('available_alliance_bond', $available_alliance_deposit_info['bond']);

                unset($offline_array);
                unset($online_array);
            }

            Tpl::output('r_f', $r_f);
            Tpl::output('online_array', $online_array);
            Tpl::output('offine_array', $offline_array);
            Tpl::output('ordername', $ordername);
            Tpl::output('study_id', $study_id);
            Tpl::output('allamount', $allamount);
            Tpl::output('order', $order);
            Tpl::showpage("cart_pay_orders");
        }
    }
    /**
     * 购物流程第一步
     */
    public function show_cart_orderOp(){
        logic_cart_manageModel::load(BUY_FROM_CART);
    }
    /**
     * 购物流程第二步
     */
    public function save_cart_orderOp(){
        logic_orderModel::submitOrder(BUY_FROM_CART);
    }
    public function getTransportOptionsOp()
    {
        $city_id = $_POST['city_id'];
        $specPostData = $_POST['specPostData'];
        $specPostData = explode(',', $specPostData);
        $options=array();
        foreach( $specPostData as $spec_id){
            $options[$spec_id]=logic_store_order_calcModel::getTransportTypeOptions($city_id,$spec_id);
        }
        echo json_encode($options);
    }
    //calc_all_priceOp
    public function calc_cart_amountOp()
    {
        //logic_cart_calc_stackModel::show();
        logic_cart_manageModel::show(BUY_FROM_CART);
    }

    /**
     * 立即购买第一步
     */
    public function show_buynow_orderOp(){
        $spec_id = intval($_GET['buynow_spec_id']);
        $logicGoods = logic_goodsModel::getObject($spec_id);
        $goods_info = $logicGoods->getGoodsInfo();
        $sql="SELECT * FROM #__jky_buy WHERE goods_serial='{$goods_info['spec_goods_serial']}' and member_id='{$_SESSION['member_id']}'";
        if(db::queryRow($sql)){
            appMessage('您已经购买过该九块邮商品，不可再次购买');
            return;
        }
        $quantity = intval($_GET['buynow_quantity']);
		if($goods_info['special_offer'] == '1' &&  $quantity>10){
			appMessage('特价产品最多只能购买10件','','error');
            	return;
		}

        // 双十活动开始
        $starttoday = strtotime(date('Y-m-d H:i:s',mktime(0,0,0,date('10'),date('10'),date('Y'))));
        $endtoday = strtotime(date('Y-m-d H:i:s',mktime(23,59,59,date('10'),date('10'),date('Y'))));
        if(time()>=$starttoday && time()<= $endtoday){
            //一元抢最多只能购买1件
            $buyLog=goodsModel::getActiviteGoods($goods_info['goods_id'],$_SESSION['member_id']);  

            if($goods_info['goods_activite_flag']==GOODS_ACTIVITE_FLAG_ONEROB &&  ($buyLog['buy_num']>=1 ||$quantity >1)) {
                appMessage('一元抢商品只能购买1件','','error');
            }
            //半价购最多只能购买5件 
            if($goods_info['goods_activite_flag']==GOODS_ACTIVITE_FLAG_HALF && (5-$buyLog['buy_num'])<$quantity) {
                appMessage('半价购商品只能购买5件','','error');
            }   
        }

        if((time()<$starttoday || time()> $endtoday) && $goods_info['goods_activite_flag']!=GOODS_ACTIVITE_FLAG_NORMAL){
             appMessage('双十活动结束，该商品暂不能购买','','error');
        }
        // 双十活动结束
        
        Tpl::output('buynow','1');
        logic_cart_manageModel::load(BUY_FROM_BUYNOW);
        //原来是cart_step1模板,分离出cart_buynow_step1模板
    }

    public function calc_buynow_amountOp()
    {
        //logic_cart_calc_stackModel::show();
        logic_cart_manageModel::show(BUY_FROM_BUYNOW);
    }

    /**
     * 购物流程第二步
     */
    public function save_buynow_orderOp() {
        logic_orderModel::submitOrder(BUY_FROM_BUYNOW);
    }

    /**
     * 组合销售购买第一步
     */
    public function show_bundling_orderOp(){
        $quantity = intval($_POST['quantity']);
        $bl_id = intval($_POST['bundling_id']);
        $bl_price = floatval($_POST['bl_price']);
        if(empty($_POST['spec']) ){
            appMessage('提交规格不能为空','index.php');
        }
        if( !is_array($_POST['spec'])){
            appMessage('提交规格不是数组','index.php');
        }
        if($quantity<=0 ){
            appMessage('购买数量不能为0','index.php');
        }
        if($bl_id<=0 ){
            appMessage('购买组合编号不能为0','index.php');
        }
        if($bl_price<=0 ){
            appMessage('购买价格不能为0','index.php');
        }
        if(empty($_POST['spec']) || !is_array($_POST['spec']) || $quantity<=0 || $bl_id<=0 || $bl_price<=0 )
        {
            appMessage('参数错误','index.php');
        }

        //检测商品是否符合购买条件
        $legalGoods_info =  logicModel::getBundlingLegalGoods($_POST['spec'], $quantity, $bl_id);
        $promotion_explain = '组合销售：每套节省'.ncPriceFormat(intval($legalGoods_info['bundling_economize'])/$quantity).'元；';
        Tpl::output('bundling_flag',true);
        //促销处理
        //满即送处理
        $mansong = logicModel::getBundlingMansong($legalGoods_info['goods_info'][0]['store_id'],$legalGoods_info['store_goods_price']);
        $legalGoods_info['store_goods_price'] -= $mansong['rule_discount'];

        if($mansong['rule_shipping_free'] === true){
            Tpl::output('bl_freight', 0);
        }else{
            Tpl::output('bl_freight', $legalGoods_info['bl_freight']);
        }

        //输出满就送活动
        Tpl::output('mansong_flag',$mansong['mansong_flag']);
        Tpl::output('rule_shipping_free',$mansong['rule_shipping_free']);
        Tpl::output('promotion_explain',$promotion_explain.$mansong['promotion_explain_show']);

        Tpl::output('store_goods_price',$legalGoods_info['store_goods_price']);

        $legalGoods_info['goods_info'][0]['store_name'] = $legalGoods_info['store_info']['store_name'];
        $legalGoods_info['goods_info'][0]['store_domain'] = $legalGoods_info['store_info']['store_domain'];

        Tpl::output('cart_array',$legalGoods_info['goods_info']);
        Tpl::output('store_info',$legalGoods_info['store_info']);

        //上一页地址
        $referer_url = getReferer();

        //实例化收货地址模型
        $sql="SELECT * FROM #__address as `address` WHERE member_id = '{$_SESSION['member_id']}' order by address_id desc";
        $address_list	= db::queryAll($sql);
        Tpl::output('address_list',$address_list);
        //如果没有参加其他活动，获取可用代金券列表
        if(C('voucher_allow') == 1 && $mansong['mansong_flag'] == false && $legalGoods_info['xianshi_flag'] ==false){
            //获取代金券列表
            $voucher_owner_id = "{$_SESSION['member_id']}";
            $voucher_store_id = "{$legalGoods_info['store_info']['store_id']}";
            $voucher_state = '1';
            $voucher_limit = $legalGoods_info['goods_info'][0]['spec_goods_price'];
            $sql="SELECT * FROM #__voucher WHERE ( voucher_owner_id = '{$voucher_owner_id}' ) AND ( voucher_store_id = '$voucher_store_id' ) AND ( voucher_state = '$voucher_state' ) AND ( voucher_limit <= '$voucher_limit' ) AND ( voucher_start_date <= '".time()."' ) AND ( voucher_end_date >= '".time()."' ) ORDER BY voucher_price asc LIMIT 1000";
            $voucher_list = db::queryAll($sql, 'voucher_id');
            Tpl::output('voucher_list',$voucher_list);
        }
        Tpl::output('bundling','1');//组合销售标记
        Tpl::output('bundling_id', $bl_id);	// 组合销售id
        $spec = '';
        foreach ($_POST['spec'] as $k=>$v){
            $spec	.= $k.':'.$v.'|';
        }
        Tpl::output('spec', rtrim($spec,'|'));	// 规格信息
        Tpl::output('quantity', $quantity);		// 数量
        Tpl::output('inc_buynow_tpl',true);
        Tpl::showpage('bundling_order');//原来是cart_step1模板,分离出cart_buynow_step1模板
    }
    /**
     * 组合销售购物流程第二步
     */
    public function save_bundling_orderOp() {
        $bl_id		= intval($_POST['bundling_id']);
        $quantity	= intval($_POST['quantity']);
        $spec_array	= explode('|', $_POST['spec']);
        $spec 		= array();
        foreach ($spec_array as $val){
            list($k,$v) = explode(':', $val);
            $spec[$k]	= $v;
        }
        $goodnums=-1;
        $jky=31;
        //上一页地址
        $referer_url = getReferer();
        $address_options = intval($_POST['address_options']);
        if ($address_options <= 0){
            appMessage('收货人地址错误',$referer_url);
        }

        $sql="SELECT * FROM #__address WHERE address_id='{$address_options}'";
        $address_info	= db::queryRow($sql);
        if (empty($address_info)){
            appMessage('收货人地址错误',$referer_url);
        }

        //获取合法的商品及总金额
        $legalGoods_info	= logicModel::getBundlingLegalGoods($spec, $quantity, $bl_id);
        $store_id			= $legalGoods_info['store_info']['store_id'];

        //添加订单中的商品信息
        $shipping_fee_total = 0;

        //实例化订单模型
        $order_class=new orderModel();
        //添加生成订单，在此步中，并没有完全生成订单，还需要接下来的其他信息进行订单填充
        $order_array		= array();
        $order_sn=orderModel::snOrder();
        $order_array['order_sn']		= $order_sn;
        $order_array['seller_id']		= $legalGoods_info['store_info']['member_id'];
        $order_array['store_id']		= $legalGoods_info['store_info']['store_id'];
        $order_array['store_name']		= $legalGoods_info['store_info']['store_name'];
        $order_array['buyer_id']		= $_SESSION['member_id'];
        $order_array['buyer_name']		= $_SESSION['member_name'];
        $order_array['buyer_email']		= $_SESSION['member_email'];
        $order_array['add_time']		= TIMESTAMP;
        $order_array['out_sn']			= $order_sn;
        $order_array['invoice']			= '';	//发票信息，暂时没有
        $order_array['evaluation_status'] = 0;
        $order_array['order_type'] 		= 0;
        $order_array['order_message']	= trim($_POST['order_message']);
        $order_array['bundling_id']		= $bl_id;
        $order_array['bundling_explain']= sprintf( '组合销售：套餐原价&yen;%01.2f，节省&yen;%01.2f。',$legalGoods_info['all_goods_price'],$legalGoods_info['bundling_economize']);
        if ($_POST['safe']=='on') {
            $order_array['safe']         =1;
            $yfpoint='true';
        }else{
            $order_array['safe']         =0;
        }
        //增加运费和配送方式
        if ($legalGoods_info['bl_freight'] != 0){
            $order_array['shipping_name']	= '快递';
            $shipping_fee_total				= $legalGoods_info['bl_freight'];
        }else{
            $order_array['shipping_name']	= '';
        }
        $output_order = $order_array;
        $order_id	= Db::insert('order',$order_array);

        $date = date('Ymd',time());
        if(!empty($legalGoods_info['goods_info'])) {
            $output_goods_name = array();
            foreach ($legalGoods_info['goods_info'] as $val) {
                $order_goods_array	= array();
                $order_goods_array['order_id']		= $order_id;
                $order_goods_array['goods_id']		= $val['goods_id'];
                $order_goods_array['goods_name']	= $val['goods_name'];
                $order_goods_array['spec_goods_serial']	= $val['spec_goods_serial'];//增加商品规格号
                $order_goods_array['stores_id']		= $val['store_id'];
                $order_goods_array['spec_id']		= $val['spec_id'];
                $order_goods_array['spec_info']		= $val['cart_spec_info'];
                $order_goods_array['goods_price']	= $val['spec_goods_price'];
                $order_goods_array['goods_num']		= $val['goods_num'];

                $goodnums+=$val['goods_num'];

                $order_goods_array['goods_image']	= $val['goods_image'];
                if (count($output_goods_name)<3) $output_goods_name[] = $val['goods_name'];
                Db::insert('order_goods',$order_goods_array);
                //删除进货车中的商品
                db::delete('cart', "spec_id= '" . $val['spec_id'] . "' and member_id= '" . $_SESSION['member_id'] . "'");

                //更新商品库存信息
                $sql = "UPDATE #__goods_spec AS goods_spec SET spec_goods_storage = spec_goods_storage - " . $val['goods_num'] . ", spec_salenum = spec_salenum + " . $val['goods_num'] . " WHERE spec_id='" . $val['spec_id'] . "'";
                db::execCommand($sql);

                $sql = "UPDATE #__goods AS goods SET salenum = salenum + " . $val['goods_num'] . " WHERE goods_id ='" . $val['goods_id'] . "'";
                db::execCommand($sql);

                //添加到销量统计表中
                $sql = "SELECT * FROM #__salenum WHERE ( date = '" . $date . "' ) AND ( goods_id = '" . $val['goods_id'] . "' ) LIMIT 1";
                $sale_date_array = db::queryRow($sql);
                if(is_array($sale_date_array) && !empty($sale_date_array)){
                    db::execCommand("UPDATE #__salenum AS `salenum` SET salenum = salenum + " . $val['goods_num']
                        . " WHERE date = '" . $date . "' AND goods_id = '" . $val['goods_id'] . "'");
                }else{
                    db::insert('salenum', array(
                            'date' => $date,
                            'salenum' => $val['goods_num'],
                            'store_id' => $store_id,
                            'goods_id' => $val['goods_id']
                        )
                    );
                }
            }
        }

        //满就送
        $mansong = logicModel::getBundlingMansong($store_id,$legalGoods_info['store_goods_price']);
        if($mansong['rule_shipping_free']) {
            $shipping_fee_total = 0;
        }

        //添加订单配送信息
        $address_array		= array();
        $address_array['order_id']		= $order_id;
        $address_array['true_name']		= $address_info['true_name'];
        $address_array['area_id']		= $address_info['area_id'];
        $address_array['area_info']		= $address_info['area_info'];
        $address_array['address']		= $address_info['address'];
        $address_array['zip_code']		= $address_info['zip_code'];
        $address_array['tel_phone']		= $address_info['tel_phone'];
        $address_array['mob_phone']		= $address_info['mob_phone'];
        $order_amount	= ncPriceFormat($legalGoods_info['store_goods_price']+$shipping_fee_total-$mansong['rule_discount']);
        Db::insert('order_address',$address_array);

        //更改订单信息，更改订单总额，商品总额，优惠价格,配送信息
        $order_sn		= $order_array['order_sn'];
        $order_array	= array();
        $order_array['goods_amount']	= $legalGoods_info['store_goods_price'];
        $order_array['discount']		= 0;
        $order_array['mansong_id']      = $mansong['mansong_info']['mansong_id'];
        $order_array['mansong_explain'] = $mansong['promotion_explain'];
        //处理代金券优惠
        $voucher_id = intval($_POST['voucher_id']);
        $voucher_price = 0;
        if($voucher_id > 0 && C('voucher_allow') && $mansong['mansong_flag']==false ) {
            //获取代金券面额
            $sql = "SELECT * FROM #__voucher WHERE ( voucher_id = '" . $voucher_id .
                "' ) AND ( voucher_owner_id = '" . $_SESSION['member_id'] .
                "' ) AND ( voucher_store_id = '" . $store_id .
                "' ) AND ( voucher_state = '1' ) AND ( voucher_limit <= '" . $order_amount .
                "' ) AND ( voucher_start_date <= '" . time() .
                "' ) AND ( voucher_end_date >= '" . time() . "' ) LIMIT 1";
            $voucherinfo = db::queryRow($sql);
            if(!empty($voucherinfo)) {
                $voucher_price = $voucherinfo['voucher_price'];
                $voucher_code = $voucherinfo['voucher_code'];
                //更改代金券状态为已使用
                db::execCommand("UPDATE #__voucher SET voucher_state='2',voucher_order_id='" . $order_id .
                    "' WHERE ( voucher_id = '" . $voucherinfo['voucher_id'] . "' )");
                //代金券模板使用数量加一
                db::execCommand("UPDATE #__voucher_template SET voucher_t_used=voucher_t_used+1 WHERE ( voucher_t_id = '" . $voucherinfo['voucher_t_id'] . "' )");
            }
        }
        if(empty($voucher_price)) {
            $order_array['voucher_id'] = 0;
            $order_array['voucher_price'] = 0;
            $order_array['voucher_code'] ='';
        }else {
            $order_array['voucher_id'] = $voucher_id;
            $order_array['voucher_price'] = $voucher_price;
            $order_array['voucher_code'] = $voucher_code;
            $order_amount -= $voucher_price;
        }

        if($store_id==$jky){
            $order_amount=(9+($goodnums*3));
        }
        if($yfpoint=='true'){
            $order_array['order_amount']=($order_amount+TRANS_INSURANCE_COST);
        }else{
            $order_array['order_amount'] 	= $order_amount;;
        }
        $order_array['order_amount'] 	= $order_amount;
        $order_array['shipping_fee']	= $shipping_fee_total;
        Db::update('order',$order_array,"order_id = '$order_id'");
        //添加订单完成阶段信息
        orderModel::addLogOrder(10,$order_id);

        $output_order = array_merge($output_order,$order_array,array('order_id'=>$order_id,'seller_name'=>$legalGoods_info['store_info']['member_name']));
        //发送邮件通知
        $param	= array(
            'site_url'		=> SiteUrl,
            'site_name'		=> $GLOBALS['setting_config']['site_name'],
            'buyer_name'	=> $_SESSION['member_name'],
            'seller_name'	=> $legalGoods_info['store_info']['member_name'],
            'order_sn'		=> $order_sn,
            'order_id'		=> $order_id
        );
        noticeModel::system_send_notice($_SESSION['member_id'],'email_tobuyer_new_order_notify',$param);
        noticeModel::system_send_notice($legalGoods_info['store_info']['member_id'],'email_toseller_new_order_notify',$param);
        @header("Location: index.php?act=order&op=order_pay&order_id=".$order_id);
        exit;
    }
    
    
    //下单判断订单商品是否含大件商品，是则隐藏货到付款选项
    public function ajaxGetCodStateOp(){
        $spec_id = intval($_GET['spec_id']);
        //立即购买
        if($spec_id > 0){
            $sql = "SELECT is_transport_dajian FROM #__goods_spec AS s LEFT JOIN #__goods AS g ON g.goods_id = s.goods_id WHERE s.spec_id = '$spec_id' AND g.store_id = '".OFFICIAL_STORE_ID."'";
            $r_f = Db::queryOne($sql);
            exit(json_encode(array('rs'=>$r_f))); 
        }else{
            $sql = "SELECT g.is_transport_dajian FROM #__cart AS c LEFT JOIN #__goods AS g ON g.goods_id = c.goods_id WHERE c.member_id = '".  intval($_SESSION['member_id']) ."' AND c.store_id = '".OFFICIAL_STORE_ID."'";
            $goods_list = Db::queryAll($sql);
            $r_f = 0;
            if(is_array($goods_list)){
                foreach($goods_list as $k=>$v){
                    if($v['is_transport_dajian'] > 0){
                        $r_f = 1;
                    }
                }
            }
            exit(json_encode(array('rs'=>$r_f))); 
        }
        
    }
}